package com.company.test;

import java.util.*;

public class Max {
  public static void main(String[] args) {
    List<String> list = Arrays.asList("adnm", "admmt", "pot", "xbanqgd", "weoujg");
    List<Integer> list1 = Arrays.asList(1, 5, 7, 11, 30, 5);
    Optional<String> op = list.stream().max(Comparator.comparing(String::length));
    System.out.println("最长的一个字符串是=" + op.get());
    Optional<Integer> num = list1.stream().max(Integer::compareTo);
    System.out.println("最大的一个数字是=" + num.get());

    List<Person> personList = new ArrayList<>();
    personList.add(new Person("Tom", 8900, 23, "male", "New York"));
    personList.add(new Person("Jack", 7000, 25, "male", "Washington"));
    personList.add(new Person("Lily", 7800, 21, "female", "Washington"));
    personList.add(new Person("Anni", 8200, 24, "female", "New York"));
    personList.add(new Person("Owen", 9500, 25, "male", "New York"));
    personList.add(new Person("Alisa", 7900, 26, "female", "New York"));

    Optional<String> name =
        personList.stream().max(Comparator.comparingInt(Person::getSalary)).map(Person::getName);
    System.out.println("员工工资最高的人是="+name.get());
  }
}
